package com.cloud.freeflow.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.freeflow.api.entity.ProcDef;
import com.cloud.freeflow.api.service.ProcDefService;
import com.cloud.freeflow.common.exception.BizException;
import com.cloud.freeflow.common.result.Quokka;

@RestController
@RequestMapping("freeflow/api/procdef")
public class ProcDefController {

	@Autowired
	private ProcDefService procDefService;

	@RequestMapping("listtree")
	public Quokka listProcDefTree(int bizId) {
		return new Quokka(true, procDefService.listProcDefTree(bizId));
	}

	@RequestMapping("detail")
	public Quokka detail(long id) {
		return new Quokka(true, procDefService.showDetail(id));
	}

	@RequestMapping("saveupdate")
	public Quokka createProcDef(@RequestBody ProcDef def) throws BizException {
		return new Quokka(true, procDefService.saveUpdateProcDef(def));
	}

	@RequestMapping("delete")
	public Quokka deleteProc(long id) {
		return new Quokka(true, procDefService.deleteProcDef(id));
	}
}
